<%@page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.gzgi.framework.*"%>
<%@ page import="com.gzgi.framework.el.*"%>
<%@ page import="com.gzgi.framework.util.*"%>
<%@ page import="com.gzgi.framework.config.*"%>
<%@ page import="com.gzgi.framework.context.*"%>
<%@ page import="com.gzgi.framework.chart.*"%>
<%@ page import="com.gzgi.framework.entity.*"%>
<%@ page import="com.gzgi.framework.dataitem.*"%>
<%@ page import="com.gzgi.framework.integration.*"%>
<%@ page import="com.gzgi.framework.sys.*"%>
<%@ page import="com.gzgi.framework.sys.model.*"%>
<%@ page import="com.gzgi.framework.sys.util.*"%>
<%@ page import="com.gzgi.crm.context.*"%>
<%@ page import="com.gzgi.crm.report.*"%>
<%@ page import="com.gzgi.crm.service.*"%>
<%@ page import="com.gzgi.crm.model.*"%>
<%@ page import="org.apache.commons.lang.StringUtils"%>
<%

		SalesContext ctx = new SalesContext();
        Map dataMap = new HashMap();
		java.util.List rows = null;
		Map userMap = null;
		ReportService reportService = null;
		try{
			  reportService = (ReportService)ContextFactory.getBean("reportService");
			  userMap = IntegrationFactory.getUserMap();
              rows = reportService.getProjectSaleLogs(ctx);
			  if(rows != null && rows.size()>0){
                 Iterator iterator = rows.iterator();
	             while(iterator.hasNext()){
		            SaleLog model = (SaleLog) iterator.next();
					SaleLog x = (SaleLog) dataMap.get(model.getProjectId());
                    if( x == null){
						x = new SaleLog();
					}
					x.setCompanyId(model.getCompanyId());
					x.setCompanyName(model.getCompanyName());
					x.setProjectId(model.getProjectId());
					x.setProject(model.getProject());
					x.setHours(x.getHours() + model.getHours());
					x.setScore(x.getScore() + model.getScore());
                    dataMap.put(x.getProjectId(), x);
				 }
			  }
		} catch(Exception ex){
            ex.printStackTrace();
	    }

		Collection c = dataMap.values();
        rows = new ArrayList();
		rows.addAll(c);
		Collections.sort(rows);
%>
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/pages/styles/styles.css" />
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/scripts/ext/resources/css/ext-all.css" />
<center><br>
<br>
<span class="subject"> <img
	src="<%=request.getContextPath()%>/pages/images/title.gif" alt="项目累计得分">
项目累计得分 </span> <br>
<br>
<table align="center" class="x-table-border" cellspacing="1"
	cellpadding="1" width="80%">
	<tr class="x-title" height="22">
		<td align="center" width="40%">项目</td>
		<td align="center" width="40%">公司</td>
		<td align="center" width="10%">用时</td>
		<td align="center" width="10%">得分</td>
	</tr>
	<%if( rows != null){
	 Iterator iterator = rows.iterator();
	 while(iterator.hasNext()){
		 SaleLog model = (SaleLog)iterator.next();
		 Project project = model.getProject();
		 pageContext.setAttribute("project", project);
	 %>
	<tr height="22" onmouseover="this.className='x-row-over';"
		onmouseout="this.className='x-row-out';" class="x-content">
		<td align="left" width="40%"><a
			href="<%=request.getContextPath()%>/crm/project.do?method=edit&projectId=<%=model.getProjectId()%>"
			target="_blank"> <c:out value="${project.projectName}" /> [<c:out
			value="${project.projectCode}" />] </a></td>
		<td align="left" width="40%"><a
			href="<%=request.getContextPath()%>/crm/company.do?method=edit&companyId=<%=model.getCompanyId()%>"
			target="_blank"> <%=model.getCompanyName()%> </a></td>
		<td align="right" width="10%"><a
			href="<%=request.getContextPath()%>/crm/saleLog.do?method=list&query_x_salelog_projectId=<%=model.getProjectId()%>"
			target="_blank"> <%=model.getHours()%>&nbsp; </a></td>
		<td align="right" width="10%"><a
			href="<%=request.getContextPath()%>/crm/saleLog.do?method=list&query_x_salelog_projectId=<%=model.getProjectId()%>"
			target="_blank"> <%=model.getScore()%>&nbsp; </a></td>
	</tr>
	<%}
}%>
</table>
<br>
</center>